/* stylelint-disable no-descending-specificity */
@import '../style/var.less';

.van-tabs {
  position: relative;
  -webkit-tap-highlight-color: transparent;

  &__wrap {
    display: flex;
    overflow: hidden;

    &--scrollable {
      .van-tab {
        flex: 0 0 22%;

        &--complete {
          flex: 1 0 auto !important;
          padding: 0 @padding-sm;
        }
      }

      .van-tabs__nav {
        &--complete {
          padding-right: 16px;
          padding-left: 16px;
        }
      }
    }
  }

  &__scroll {
    width: 100%;
    .theme(background-color, '@tabs-nav-background-color');

    &--line {
      box-sizing: content-box;
      // 30px padding to hide scrollbar in mobile safari
      height: calc(100% + 30px);
    }

    &--card {
      box-sizing: border-box;
      .theme(margin, '0 @padding-md');
      .theme(border, '@border-width-base solid @tabs-default-color');
      .theme(width, 'calc(100% - calc(@padding-md * 2))');
      .theme(border-radius, '@border-radius-sm');
    }

    &::-webkit-scrollbar {
      display: none;
    }
  }

  &__nav {
    position: relative;
    display: flex;
    user-select: none;

    &--card {
      margin: -1px;
      box-sizing: border-box;
      .theme(height, '@tabs-card-height');
      .theme(border, '@border-width-base solid @tabs-default-color');
      .theme(border-radius, '@border-radius-sm');

      .van-tab {
        .theme(color, '@tabs-default-color');
        .theme(line-height, 'calc(@tabs-card-height - 2 * @border-width-base)');
        .theme(border-right, '@border-width-base solid @tabs-default-color');

        &:last-child {
          border-right: none;
        }

        &.van-tab--active {
          .theme(color, '@white');
          .theme(background-color, '@tabs-default-color');
        }

        &--disabled {
          .theme(color, '@tab-disabled-text-color');
        }
      }
    }
  }

  &__line {
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 1;
    .theme(height, '@tabs-bottom-bar-height');
    .theme(border-radius, '@tabs-bottom-bar-height');
    .theme(background-color, '@tabs-bottom-bar-color');
  }

  &__track {
    position: relative;
    width: 100%;
    height: 100%;

    &--animated {
      display: flex;
      transition-property: left;
    }
  }

  &__content {
    overflow: hidden;
  }

  &--line {
    .van-tabs__wrap {
      .theme(height, '@tabs-line-height');
    }
  }

  &--card {
    .van-tabs__wrap {
      .theme(height, '@tabs-card-height');
    }
  }
}

.van-tab {
  flex: 1;
  box-sizing: border-box;
  min-width: 0;

  /* hack for flex ellipsis */
  padding: 0 10px;
  text-align: center;
  cursor: pointer;
  position: relative;
  .theme(color, '@tab-text-color');
  .theme(font-size, '@tab-font-size');
  .theme(line-height, '@tabs-line-height');

  &--active-line {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;

    .theme(height, '@tabs-bottom-bar-height');

    .theme(background-color, '@primary-color');

    border-radius: 4px;
  }

  &--active-line-show {
    animation: tab-line-show @tabs-bottom-bar-duration;
    animation-fill-mode: forwards;
  }

  &--active-line-hidden {
    animation: tab-line-hidden @tabs-bottom-bar-duration;
    animation-fill-mode: forwards;
  }

  @keyframes tab-line-show {
    from {
      width: 0%;
    }

    to {
      .theme(width, '@tabs-bottom-bar-width');
    }
  }

  @keyframes tab-line-hidden {
    from {
      .theme(width, '@tabs-bottom-bar-width');
    }

    to {
      width: 0%;
    }
  }

  &--active {
    .theme(font-weight, '@font-weight-bold');
    .theme(color, '@tab-active-text-color');
  }

  &--disabled {
    .theme(color, '@tab-disabled-text-color');
  }

  &__title {
    &__info {
      position: relative !important;
      top: -2px !important;
      // display: inline-block;
      padding-top: 3px;
      transform: translateX(0) !important;
    }

    .van-info--dot {
      border-radius: 100%;
      .theme(width, '@info-dot-size');
      .theme(height, '@info-dot-size');
    }
  }
}
